package com.broadsoft.platform.wfengine.runtime.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.broadsoft.platform.wfengine.NodeType;
import com.broadsoft.platform.wfengine.runtime.WfContext;
import com.broadsoft.platform.wfengine.runtime.WfEngine;

public class SplitRunnable implements Runnable {

    private final static Logger logger = LoggerFactory.getLogger(SplitRunnable.class);
    
    private final NodeType currentNode;

    private final WfContext flowContext;
    
    private final WfEngine wfEngine;
 

    public SplitRunnable(NodeType currentNode, WfContext flowContext,WfEngine wfEngine) { 
        this.currentNode=currentNode;
        this.flowContext=flowContext;
        this.wfEngine=wfEngine;
    }

    public void run() { 
        if(logger.isDebugEnabled()){
            logger.trace("The method[run] begin at the thread {}.",Thread.currentThread().getName());
            logger.trace("The variable[wfEngine] is {}.",wfEngine);
            logger.trace("The variable[currentNode] is {}.",currentNode);
            logger.trace("The variable[flowContext] is {}.",flowContext);
        }
        try {
            wfEngine.executeNode(currentNode, flowContext);
        } catch (Exception e) { 
            e.printStackTrace();
        }
        if(logger.isDebugEnabled()){
            logger.trace("The method[run] end at the thread {}.");
        }
    }

}